#ifndef __SCDES_H
#define __SCDES_H

#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pthread.h>
#include <sched.h>
#include <limits.h>
#include <time.h>
#include <sys/time.h>

#ifdef __cplusplus
extern "C" {
#endif

#define __MACRO_VARARGS_SUPPORTED__

#undef LIBCTOR
#define LIBCTOR
#undef LIBDTOR
#define LIBDTOR

#define LIBEXPORTSYMBOL
#define LIBIMPORTSYMBOL
#define LIBSYMBOL

#define MAIN scdesmain
#ifdef __cplusplus
#define MAINTYPE extern "C" int
#else
#define MAINTYPE int
#endif
#define SCOS_MTU 1024
#define restrict
#define IABS(a)      abs(a)
#define ICLIPI(a, b) (((a)<(b))?(a):(b))

#define DES

typedef struct
{
  int val, thread, signal;
} scos_mutex_t;

typedef int scos_thread_t;
typedef int scos_cond_t;
typedef int SOCKET;

LIBSYMBOL int  scos_thread_create(scos_thread_t *thread, void *(*func)(void*), void *arg);
LIBSYMBOL int  scos_thread_create_dma(scos_thread_t *thread, void *(*func)(void*), void *arg);
LIBSYMBOL int  scos_thread_join(scos_thread_t *thread);
LIBSYMBOL int  scos_mutex_init(scos_mutex_t *mutex);
LIBSYMBOL int  scos_mutex_destroy(scos_mutex_t *mutex);
LIBSYMBOL int  scos_mutex_lock(scos_mutex_t *mutex);
LIBSYMBOL int  scos_mutex_unlock(scos_mutex_t *mutex);
LIBSYMBOL int  scos_mutex_trylock(scos_mutex_t *mutex);
LIBSYMBOL int  scos_cond_init(scos_cond_t *cond);
LIBSYMBOL int  scos_cond_wait(scos_cond_t *cond, scos_mutex_t *mutex);
LIBSYMBOL int  scos_cond_signal(scos_cond_t *cond);
LIBSYMBOL int  scos_cond_destroy(scos_cond_t *cond);
LIBSYMBOL int  scos_self(void);
LIBSYMBOL int  scos_yield(void);
LIBSYMBOL void scos_usleep(unsigned long time);
LIBSYMBOL void scos_delay(unsigned long time);
LIBSYMBOL void scos_dissipate(double energy);
LIBSYMBOL int  scos_gettimeofday(struct timeval *tv, void *tz);
LIBSYMBOL int  scos_unsupported(char *msg);

#define scos_socket(af, type, protocol)       scos_unsupported ("scos_socket")
#define scos_accept(s, addr, addrlen)         scos_unsupported ("scos_accept")
#define scos_bind(s, addr, addrlen)           scos_unsupported ("scos_bind")
#define scos_connect(s, addr, addrlen)        scos_unsupported ("scos_connect")
#define scos_recv(s, buf, len, flags)         scos_unsupported ("scos_recv")
#define scos_send(s, buf, len, flags)         scos_unsupported ("scos_send")
#define scos_close(s)                         scos_unsupported ("scos_close")
#define scos_listen(s, backlog)               scos_unsupported ("scos_listen")
#define scos_sendto(s, msg, len, flags, to, tolen) scos_unsupported ("scos_sendto")
#define scos_setsockopt(s, level, optname, optval, optlen) scos_unsupported ("scos_setsockopt")

#define scos_setpreempt(state)
#define scos_trace(val)

#ifdef __cplusplus
}
#endif

#endif /* __SCDES_H */
